<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function add() {
				//var num1Input = document.getElementById('num1');
				//var num1 = num1Input.value;
				var num1 = document.getElementById('num1Id').value;
				var num2 = document.getElementById('num2Id').value;
				var result = parseInt(num1) + parseInt(num2);
				var resultInput	= document.getElementById('resultId')
				resultInput.value = result;
			}
			
			function sub() {
				var num1 = document.getElementById('num1Id').value;
				var num2 = document.getElementById('num2Id').value;
				var result = parseInt(num1) - parseInt(num2);
				var resultInput	= document.getElementById('resultId')
				resultInput.value = result;
			}
			
			function mul() {
				var num1 = document.getElementById('num1Id').value;
				var num2 = document.getElementById('num2Id').value;
				var result = parseInt(num1) * parseInt(num2);
				var resultInput	= document.getElementById('resultId')
				resultInput.value = result;
			}
			
			function div() {
				var num1 = document.getElementById('num1Id').value;
				var num2 = document.getElementById('num2Id').value;
				var result = parseInt(num1) / parseInt(num2);
				var resultInput	= document.getElementById('resultId')
				resultInput.value = result;
			}
		</script>
	</head>
	<body>
		<table>
			<tr>
				<td><img src="shop.jpg" /></td>
				<td colSpan="3">购物简易计算器</td>
			</tr>
			<tr>
				<td>第一个数</td>
				<td colSpan="3">
					<input type="text" id="num1Id" />
				</td>
			</tr>
			<tr>
				<td>第二个数</td>
				<td colSpan="3">
					<input type="text" id="num2Id" />
				</td>
			</tr>
			<tr>
				<td>
					<input type="button" value=" + " onclick="add()" />
				</td>
				<td>
					<input type="button" value=" - " onclick="sub()" />
				</td>
				<td>
					<input type="button" value=" * " onclick="mul()" />
				</td>
				<td>
					<input type="button" value=" / " onclick="div()" />
				</td>
			</tr>
			<tr>
				<td>计算结果</td>
				<td colSpan="3">
					<input type="text" id="resultId" />
				</td>
			</tr>
		</table>
	</body>
</html>
